﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace SARControlLib
{
	/// <summary>
	/// SARTarget.xaml 的交互逻辑
	/// </summary>
	public partial class SARTarget : UserControl
	{
		public SARTarget()
		{
			this.InitializeComponent();
		}

        private TargetNote tagetNote = new TargetNote();

        public TargetNote SARTagetNote
        {
            get { return tagetNote; }
            set { tagetNote = value; }
        }

        private double angle;
        /// <summary>
        /// 目标所在的角度
        /// </summary>
        public double SARAngle
        {
            get { return angle; }
            set { angle = value; }
        }

        private double distance;
        /// <summary>
        /// 目标相对于中心的距离，单位为m
        /// </summary>
        public double SARDistance
        {
            get { return distance; }
            set { distance = value; }
        }

        private double direct = 0;
        /// <summary>
        /// 目标的运动方向
        /// </summary>
        public double SARDirect
        {
            get { return direct; }
            set { 
                direct = value;
                rotTansf.Angle = value + 225;
            }
        }

        private bool showDirect = true;

        /// <summary>
        /// 是否显示拖尾
        /// </summary>
        public bool SARShowDirect
        {
            get { return showDirect; }
            set
            {
                showDirect = value;
                if (value)
                {
                    this.tale.Visibility = System.Windows.Visibility.Visible;
                }
                else
                {
                    this.tale.Visibility = System.Windows.Visibility.Hidden;
                }
            }
        }
        



        /// <summary>
        /// 是否被选中
        /// </summary>
        private bool isSelected;

        public bool SARIsSelected
        {
            get { return isSelected; }
            set { isSelected = value; }
        }

        private string posture;
        /// <summary>
        /// 姿态
        /// </summary>
        public string SARPosture
        {
            get { return posture; }
            set { posture = value; }
        }

        private double speed;
        /// <summary>
        /// 速度
        /// </summary>
        public double SARSpeed
        {
            get { return speed; }
            set { speed = value; }
        }

        private double acceleration;
        /// <summary>
        /// 加速度
        /// </summary>
        public double SARAcceleration
        {
            get { return acceleration; }
            set { acceleration = value; }
        }

        private int objectType=0;
        public int SARObjectType
        {
            get { return objectType; }
            set
            {
                objectType = value;
                type1.Visibility = System.Windows.Visibility.Hidden;
                type2.Visibility = System.Windows.Visibility.Hidden;
                type3.Visibility = System.Windows.Visibility.Hidden;
                if (objectType == 0)
                {
                    type1.Visibility = System.Windows.Visibility.Visible;
                }
                else if (objectType == 1)
                {
                    type2.Visibility = System.Windows.Visibility.Visible;
                }
                else if (objectType == 2)
                {
                    type3.Visibility = System.Windows.Visibility.Visible;
                }
            }
        }

        private void root_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            isSelected = !isSelected;
            if (isSelected)
            {
                if (objectType == 0)
                {
                    path1.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                    path2.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                    path3.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                }
                else if (objectType == 1)
                {
                    path4.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                    path5.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                    path6.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                }
                else if (objectType == 2)
                {
                    path7.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                    path8.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                    path9.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                }
                path10.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                path11.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
                path12.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0x88, 0xaa));
            }
            else
            {
                if (objectType == 0)
                {
                    path1.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                    path2.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                    path3.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                }
                else if (objectType == 1)
                {
                    path4.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                    path5.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                    path6.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                }
                else if (objectType == 2)
                {
                    path7.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                    path8.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                    path9.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                }
                path10.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                path11.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
                path12.Fill = new SolidColorBrush(Color.FromRgb(0x66, 0xb0, 0x16));
            }            
        }        
	}
}